<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of actions
 *
 * @author aa
 */
class homeActions extends sfActions {

    /**
     * Renders Register form
     */
    public function executeRegisterForm(){
        $this->form = new RegisterForm();
    }

    /**
     * Execute registration logic, and save to database
     * @param sfWebRequest $request
     */
    public function executeRegister(sfWebRequest $request){
        //$this->debug($request->getPostParameters());
        $this->form = new RegisterForm();
        $this->form->bind($request->getPostParameters());
        if($this->form->isValid()){
            $this->form->save();
            //$this->getUser()->setFlash('notice', 'Success');
            //Redirects for avoiding form re-submition
            $success_url = $this->generateUrl('register_success', array(), true);
            $this->redirect($success_url);
        } else {
            $this->getUser()->setFlash('error', 'The item has not been saved due to some errors');
        }
        $this->setTemplate('registerForm');
    }

    /**
     * Display message to user
     * @param sfWebRequest $request
     */
    public function executeRegisterSuccess(sfWebRequest $request){
        
    }

    private function debug($params, $exit = true){
        echo '<pre>'; print_r($params); echo '</pre>';
        if($exit){
            exit();
        }
    }
}
?>
